package com.alatus;

import com.alatus.utils.GameUtil;

/**
 * 初始化地雷
 */
public class BottomMine {
//    存放坐标
    private static int[] mines = new int[GameUtil.MINE_MAX * 2];
//    地雷坐标
    private int x,y;
//    是否放置
    private boolean isPlace = true;
    public void newMine() {
        for (int i = 0; i < GameUtil.MINE_MAX * 2; i=i+2) {
//            加一是为了让随机数从0到1变为1到12
            x = (int) (Math.random() * GameUtil.MAP_WIDTH + 1);
            y = (int) (Math.random() * GameUtil.MAP_HEIGHT + 1);
            for (int j = 0; j < i; j=j+2) {
                if(x == mines[j] && y == mines[j + 1]){
                    i = i - 2;
                    isPlace = false;
                    break;
                }
            }
            if(isPlace){
                mines[i] = x;
                mines[i + 1] = y;
            }
            isPlace = true;
        }
        for (int i = 0; i < GameUtil.MINE_MAX * 2; i=i+2) {
            GameUtil.DATA_BOTTOM[mines[i]][mines[i + 1]] = -1;
        }
    }
}
